﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;

namespace VikingArcade_v2._0
{
    public class UserInterfaceController : IGameStateObserver
    {
        public UserInterface UserInterface { get; set; }

        public UserInterfaceController()
        {
            UserInterface = InterfaceFactory.CreateUserInterface(GameState.Initializing);
            DisplayController.FullScreenToggled += new DisplayController.OnToggleFullScreen(FullScreenToggled);
        }

        void FullScreenToggled(System.Drawing.Size oldSize, System.Drawing.Size newSize)
        {
            UserInterface.ResizeControls(oldSize, newSize);
        }

        public void UpdateInput()
        {
            if(UserInterface.IsKeyPressed(Keys.Escape))
            {
                Router.GameState = GameState.Quit;
            }

            if(UserInterface.IsKeyPressed(Keys.F6))
            {
                DisplayController.ToggleFullScreen();
            }
            
            UserInterface.UpdateInput();
        }

        public void Notify(GameState gameState)
        {
            UserInterface = InterfaceFactory.CreateUserInterface(gameState);
        }
    }
}
